﻿@model ProductDetailsModel
@using Nop.Core;
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Orders;
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Web;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title, meta
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(productUrl);
    }
}

<!--product breadcrumb-->
@Html.Action("ProductBreadcrumb", "Catalog", new { productId = Model.Id })
<div class="page product-details-page">
    <div class="page-body">
        @Html.Widget("productdetails_top")
        @using (Html.BeginRouteForm("Product", new { SeName = Model.SeName }, FormMethod.Post, new { id = "product-details-form" }))
        {
            <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
                <div class="product-essential">
                    @Html.Widget("productdetails_before_pictures")
                    <!--product pictures-->
                    @Html.Partial("_ProductDetailsPictures", Model)
                    @Html.Widget("productdetails_after_pictures")
                    <div class="overview">
                        <div class="product-name">
                            <h1 itemprop="name">
                                @Model.Name
                            </h1>
                        </div>
                        @if (!String.IsNullOrEmpty(Model.ShortDescription))
                        {
                            <div class="short-description">
                                @Html.Raw(Model.ShortDescription)
                            </div>
                        }
                        @Html.Widget("productdetails_overview_top")

                        <!--product manufacturers-->
                        @Html.Action("ProductManufacturers", "Catalog", new { productId = Model.Id })

                        <!--product reviews-->
                        @Html.Action("ProductReviewOverview", "Catalog", new { productId = Model.Id })

                        <div class="add-info">
                            @Html.Action("CompareProductsButton", "Catalog", new { productId = Model.Id })
                            @Html.Action("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id })
                        </div>
                        <!--add-info-->

                        @Html.Action("ShareButton", "Catalog")

                        @Html.Widget("productdetails_overview_bottom")

                    </div>

                    @if (!String.IsNullOrEmpty(Model.FullDescription))
                    {
                        <div class="full-description" itemprop="description">
                            @Html.Raw(Model.FullDescription)
                        </div>
                    }

                    @Html.Widget("productdetails_before_collateral")
                </div>

                <div class="product-collateral">
                    <!--associated products-->
                    <div class="product-variant-list">
                        @foreach (var variant in Model.AssociatedProducts)
                        {
                            <div class="product-variant-line" data-productid="@variant.Id">

                                @if (!String.IsNullOrWhiteSpace(variant.DefaultPictureModel.ImageUrl))
                                {
                                    <div class="variant-picture">
                                        <img alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl"
                                             title="@variant.DefaultPictureModel.Title" id="main-product-img-@variant.Id" />
                                    </div>
                                }

                                <div class="variant-overview">
                                    @if (!String.IsNullOrWhiteSpace(variant.Name))
                                    {
                                        <div class="variant-name">
                                            @variant.Name
                                        </div>
                                    }

                                    @if (!String.IsNullOrWhiteSpace(variant.ShortDescription))
                                    {
                                        <div class="variant-description">
                                            @Html.Raw(variant.ShortDescription)
                                        </div>
                                    }

                                    <div class="add-info">
                                        <!--product SKU, manufacturer part number, stock info-->
                                        @Html.Partial("_SKU_Man_Stock", variant)

                                        @if (!variant.AddToCart.DisableWishlistButton)
                                        {
                                            <input type="button" class="add-to-wishlist-button" value="@T("ShoppingCart.AddToWishlist")" data-productid="@variant.AddToCart.ProductId" onclick="AjaxCart.addproducttocart_details('@Url.RouteUrl("AddProductToCart-Details", new { productId = variant.AddToCart.ProductId, shoppingCartTypeId = (int)ShoppingCartType.Wishlist })    ', '#product-details-form');return false;" />
                                        }

                                        @Html.Partial("_DownloadSample", variant)

                                        <!--Back in stock subscription-->
                                        @Html.Partial("_BackInStockSubscription", variant)

                                    </div>
                                    <!--add-info-->

                                    <div class="buy-panel">

                                        @{
                                            var dataDictAttributes = new ViewDataDictionary();
                                            dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", variant.Id);
                                            @Html.Partial("_ProductAttributes", variant.ProductVariantAttributes, dataDictAttributes)                   
                                        }

                                        @Html.Action("ProductTierPrices", "Catalog", new { productId = variant.Id })

                                        <div class="order-line">
                                            @{
                                                var dataDictPrice = new ViewDataDictionary();
                                                dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", variant.Id);
                                                @Html.Partial("_ProductPrice", variant.ProductPrice, dataDictPrice)
                                            }
                                            @{
                                                var dataDictAddToCart = new ViewDataDictionary();
                                                dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", variant.Id);
                                                @Html.Partial("_AddToCart", variant.AddToCart, dataDictAddToCart)
                                            }
                                        </div>
                                        <!--order-line-->
                                    </div>
                                    <!--buy-panel-->
                                </div>
                                <!--overview-->

                                @{
                                    var dataDictGiftCard = new ViewDataDictionary();
                                    dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", variant.Id);
                                    @Html.Partial("_GiftCardInfo", variant.GiftCard, dataDictGiftCard)
                                }

                            </div>
                            <!--product-variant-line-->

                        }
                    </div>

                    @if (Model.AssociatedProducts.Count == 0)
                    {
                        <div class="no-associated-products">
                            @T("Products.NoAssociatedProducts")
                        </div>
                    }

                    <div>
                        @Html.Action("ProductSpecifications", "Catalog", new { productId = Model.Id })
                    </div>

                    <div>
                        @Html.Action("ProductTags", "Catalog", new { productId = Model.Id })
                    </div>
                </div>
            </div>
        }
    </div>
</div>
@Html.Action("RelatedProducts", "Catalog", new { productId = Model.Id })

@Html.Action("ProductsAlsoPurchased", "Catalog", new { productId = Model.Id })

@Html.Widget("productdetails_bottom")